﻿<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
	<Style TargetType="{x:Type Button}">
		<Setter Property="Background" 
				Value="Transparent" />
		<Setter Property="Foreground" 
				Value="Transparent" />
		<Setter Property="BorderBrush" 
				Value="Transparent" />
	</Style>
	<Style TargetType="{x:Type Expander}">
		<Setter Property="Template">
			<Setter.Value>
				<ControlTemplate TargetType="{x:Type Expander}">
					<Grid Background="Transparent" 
						  x:Name="Border" 
						  Margin="0" >
						<!-- Template consists of a dockpanel with a ToggleButton docked to the left side, giving the remaining space to a ContentPresenter-->
						<DockPanel x:Name="DockPanel">
							<!-- HEADER
                                     The IsChecked property is bound to the Expander's IsExpanded
                                     The Content property is bound to the Expander's Header -->
							<ToggleButton IsChecked="{Binding IsExpanded, Mode=TwoWay, RelativeSource={RelativeSource TemplatedParent}}"
                                              DockPanel.Dock="Left" 
                                              x:Name="ExpanderHeader" 
                                              Content="{TemplateBinding Header}" 
                                              Width="28">
								<ToggleButton.Style>
									<Style TargetType="{x:Type ToggleButton}">
										<Setter Property="Template">
											<Setter.Value>
												<ControlTemplate TargetType="{x:Type ToggleButton}">
													<!-- HEADER: The Toggle button is drawn by a rectangle; Content (above) is defined by a ContentPresenter-->
													<Grid  Margin="0"  x:Name="ExpanderHeader">
														<Rectangle RadiusX="50" 
																   RadiusY="0"
																   x:Name="ExpanderHeaderBackground"
																   Grid.Column="0"
																   Grid.ColumnSpan="1"
																   Grid.Row="0"
																   HorizontalAlignment="Stretch"
																   VerticalAlignment="Stretch">
															<Rectangle.Fill>
																<LinearGradientBrush  StartPoint="0,0" 
																					  EndPoint="1,0">
																	<GradientStop Offset="1" 
																				  Color="OliveDrab" />
																	<GradientStop Color="GreenYellow" 
																				  Offset="0"/>

																</LinearGradientBrush>
															</Rectangle.Fill>
														</Rectangle>
														<ContentPresenter DataContext="{x:Null}" 
																		  TextBlock.FontSize="18" 
																		  TextBlock.TextAlignment="Right" 
																		  TextBlock.FontFamily="Fonts/SegoeWP.ttf#Segoe WP" 
																		  TextBlock.Foreground="White" 
																		  HorizontalAlignment="Center" 
																		  VerticalAlignment="Stretch" 
																		  Margin="0,15,0,0" 
																		  Grid.Column="1" 
																		  x:Name="ContentSite" 
																		  Content="{TemplateBinding Content}" 
																		  ContentTemplate="{TemplateBinding ContentTemplate}" 
																		  ContentTemplateSelector="{TemplateBinding ContentTemplateSelector}" 
																		  RecognizesAccessKey="True">
															<ContentPresenter.LayoutTransform>
																<RotateTransform Angle="270"/>
															</ContentPresenter.LayoutTransform>
														</ContentPresenter>
													</Grid>
													<!-- HEADER: When pressed will be higlighted -->
													<ControlTemplate.Triggers>
														<Trigger Property="IsPressed"
																 Value="true">
															<Setter TargetName="ExpanderHeaderBackground" 
																	Property="Fill">
																<Setter.Value>
																	<LinearGradientBrush  StartPoint="0,0" 
																						  EndPoint="1,0">
																		<GradientStop Offset="0" 
																					  Color="Salmon" />
																		<GradientStop Color="DarkGray" 
																					  Offset="0.75"/>
																	</LinearGradientBrush>
																</Setter.Value>
															</Setter>
														</Trigger>
													</ControlTemplate.Triggers>
												</ControlTemplate>
											</Setter.Value>
										</Setter>
									</Style>
								</ToggleButton.Style>
							</ToggleButton>
							<!-- CONTENT -->
							<ContentPresenter DockPanel.Dock="Bottom" 
											  Width="{Binding ControlWidth}" 
											  MinWidth="0" 
											  x:Name="ExpanderPanel" 
											  RenderTransformOrigin="0.5,0.5"  >
								<ContentPresenter.LayoutTransform>
									<TransformGroup >
										<ScaleTransform x:Name="LayoutScaleTransform" 
														ScaleX="1" 
														ScaleY="1" />
									</TransformGroup>
								</ContentPresenter.LayoutTransform>
							</ContentPresenter>
						</DockPanel>
					</Grid>

					<!-- Triggers for animation-->
					<ControlTemplate.Triggers>
						<Trigger Property="IsExpanded" 
								 Value="False">
							<Trigger.EnterActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Timeline.DesiredFrameRate="20" 
														 BeginTime="00:00:00" 
														 Storyboard.TargetName="LayoutScaleTransform"
														 Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
														 From="1" To="0" 
														 Duration="0:0:0.25" />
									</Storyboard>
								</BeginStoryboard>
							</Trigger.EnterActions>
							<Trigger.ExitActions>
								<BeginStoryboard>
									<Storyboard>
										<DoubleAnimation Timeline.DesiredFrameRate="20" 
														 BeginTime="00:00:00" 
														 Storyboard.TargetName="LayoutScaleTransform"
														 Storyboard.TargetProperty="(ScaleTransform.ScaleX)"
														 From="0" To="1" 
														 Duration="0:0:0.25" />
									</Storyboard>
								</BeginStoryboard>
							</Trigger.ExitActions>
						</Trigger>
					</ControlTemplate.Triggers>
				</ControlTemplate>
			</Setter.Value>
		</Setter>
	</Style>

</ResourceDictionary>